package com.hopu.v1.controller.front.personal;

import com.hopu.v1.pojo.common.PageData;
import com.hopu.v1.pojo.common.R;
import com.hopu.v1.pojo.verify.StudentLeaveApplications;
import com.hopu.v1.service.front.personal.FStudentLeaveService;
import com.hopu.v1.vo.StudentLeaveVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: YwaiX
 * @Version: 1.0
 * @Date: Created in 2024-10-11 19:23:43
 * @Description: 请假
 */

@RestController
@RequestMapping("api/v1/front/leave")
public class FStudentLeaveController {
	
	@Autowired
	private FStudentLeaveService fStudentLeaveService;
	
	/**
	 * 分页模糊查询请假记录
	 * @param page
	 * @param size
	 * @param leaveType
	 * @return
	 */
	@GetMapping
	public R getStudentLeaveList(Integer page , Integer size , Integer leaveType,Integer studentId){
		 PageData<StudentLeaveVo> pageData = fStudentLeaveService.getStudentLeaveList(page,size,leaveType,studentId);
		 return R.ok(pageData);
	}
	
	/**
	 * 获取请假审批人信息
	 * @param studentId
	 * @return
	 */
	@GetMapping("getApproves")
	public R getApproves(Integer studentId){
		return R.ok(fStudentLeaveService.getApproves(studentId));
	}
	
	/**
	 * 添加请假申请记录
	 * @param studentLeaveApplications
	 * @return
	 */
	@PostMapping
	public R insertStudentLeave(@RequestBody StudentLeaveApplications studentLeaveApplications){
		fStudentLeaveService.insertStudentLeave(studentLeaveApplications);
		return R.ok("添加成功");
	}
}
